<template>
    <div class="play_ctrl">
      <div class="left">
        <img :src="playList.tracks[current_index].al.picUrl" alt="">
        <div class="content">
          <div class="title">{{ playList.tracks[current_index].name }}</div>
          <div class="text">横滑可以切换上下首哦</div>
        </div>
      </div>
      <div class="right">
        <svg v-if="paused" @click="play" class="icon" aria-hidden="true">
          <use xlink:href="#icon-bofang"></use>
        </svg>
        <svg v-else @click="play" class="icon" aria-hidden="true">
          <use xlink:href="#icon-zanting"></use>
        </svg>
        <svg class="icon" aria-hidden="true">
          <use xlink:href="#icon-liebiao"></use>
        </svg>
      </div>
      <audio autoplay ref="audio" :src="`http://music.163.com/song/media/outer/url?id=${playList.tracks[current_index].id}.mp3`"></audio>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import {getSong}  from "@/api/index"
export default {
  data(){
    return {
      id:0,
      paused:true
    }
  },
  computed:{
    ...mapState([
      'playList','current_index'
    ])
  },
  mounted() {
    this.play()
  },
  methods:{
    play(){
      if(this.$refs.audio.paused){
        this.$refs.audio.play()
        this.paused=false;
      }else {
        this.$refs.audio.pause()
        this.paused=true
      }
    }
  }
}
</script>

<style scoped lang="less">
.play_ctrl{
  position: fixed;
  bottom: 0;
  left: 0;
  width: 7.5rem;
  height: 1rem;
  background-color: #fff;
  border-top: 1px solid #ededed;
  padding: 0 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .content{
      .title{
        font-size: 0.24rem;
        margin-bottom: 0.1rem;
      }
      .text{
        font-size: 0.20rem;
        color: #999;
      }
    }
    img{
      width: 0.7rem;
      height: 0.7rem;
      border-radius: 100%;
      margin-right: 0.3rem;
    }
  }
  .right{
    .icon{
      margin-left: 0.3rem;
      width: 0.45rem;
      height: 0.45rem;
    }
  }
}
</style>
